//
//  MainHomeViewTabBarController.m
//  Romens.XSBalance
//
//  Created by 李美东 on 16/2/23.
//  Copyright © 2016年 孙博. All rights reserved.
//

#import "MainHomeViewTabBarController.h"
#import "MyViewController.h"
#import "TendencyViewController.h"
#import "MeasureViewController.h"
@interface MainHomeViewTabBarController ()
{
    MyViewController * _myVC;
    TendencyViewController * _tendencyVC;
    MeasureViewController * _measureVC;
}
@end

@implementation MainHomeViewTabBarController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
    }
    return self;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
    return (toInterfaceOrientation == UIInterfaceOrientationPortrait);
}
- (BOOL)shouldAutorotate
{
    return NO;
}
- (UIInterfaceOrientationMask)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskPortrait;//只支持这一个方向(正常的方向)
}
- (id)init {
    self = [super init];
    if (self) {
           }
    return self;
}
- (void)viewDidLoad
{
    [super viewDidLoad];
    [self SetSubViews];
}
- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
}

- (void)dealloc
{
    
}

-(void)SetSubViews
{
   self.edgesForExtendedLayout = UIRectEdgeNone;
    _measureVC=[[MeasureViewController alloc] init];
   // _measureVC.title=@"测量";
    UINavigationController *N_measureVC=[[UINavigationController alloc] initWithRootViewController:_measureVC];
    
    N_measureVC.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"测量"
                                                            image:[UIImage imageNamed:@"measure"]
                                                              tag:0];
    
    [N_measureVC.tabBarItem setSelectedImage:[[UIImage imageNamed:@"measure_chosed"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]] ;
    
    [self unSelectedTapTabBarItems:N_measureVC.tabBarItem];
    [self selectedTapTabBarItems:N_measureVC.tabBarItem];
    
    
    
    _tendencyVC=[[TendencyViewController alloc] init];
    UINavigationController *N_tendencyVC=[[UINavigationController alloc] initWithRootViewController:_tendencyVC];
  //  _tendencyVC.title=@"趋势";
    N_tendencyVC.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"趋势"
                                                                image:[UIImage imageNamed:@"trend"]
                                                                  tag:1];
    [N_tendencyVC.tabBarItem setSelectedImage:[[UIImage imageNamed:@"trend_chosed"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]] ;
    [self unSelectedTapTabBarItems:N_tendencyVC.tabBarItem];
    [self selectedTapTabBarItems:N_tendencyVC.tabBarItem];
    
    _myVC = [[MyViewController alloc] init];
    UINavigationController *N_myVC=[[UINavigationController alloc] initWithRootViewController:_myVC];
    _myVC.title=@" ";
    N_myVC.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"我的"
                                                            image:[UIImage imageNamed:@"ic-contacts-n"]
                                                              tag:2];
    [N_myVC.tabBarItem setSelectedImage:[[UIImage imageNamed:@"ic-contacts-h"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]] ;
    _myVC.view.autoresizingMask = UIViewAutoresizingNone;
    [self unSelectedTapTabBarItems:N_myVC.tabBarItem];
    [self selectedTapTabBarItems:N_myVC.tabBarItem];
    
    self.viewControllers = @[N_measureVC,N_tendencyVC,N_myVC];
    [self selectedTapTabBarItems:N_measureVC.tabBarItem];
}
-(void)unSelectedTapTabBarItems:(UITabBarItem *)tabBarItem
{
    [tabBarItem setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
                                        [UIFont systemFontOfSize:14], UITextAttributeFont,[UIColor lightGrayColor],UITextAttributeTextColor,
                                        nil] forState:UIControlStateNormal];
}

-(void)selectedTapTabBarItems:(UITabBarItem *)tabBarItem
{
    [tabBarItem setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
                                        [UIFont systemFontOfSize:14],
                                        UITextAttributeFont,SystemColor,UITextAttributeTextColor,
                                        nil] forState:UIControlStateSelected];
}

@end
